<?php 
// no direct access
defined('_JEXEC') or die('Restricted access');

//$template_dir = $this->baseurl.'/templates/mwc_careitec/assets/';
$template_dir = '/templates/mwc_careitec/assets/';
jimport('mylibs.globalModel');
$globalModel = new globalModel();
       
$menu_id = JRequest::getVar('Itemid', 0, 'get');
$cat_id = JRequest::getVar('category_id', 0, 'get');
$layout = JRequest::getVar('layout', 0, 'get');
$emulate = JRequest::getVar('emulate', 0, 'get'); 
$current_id = JRequest::getVar('id', 0, 'get');  
$success = JRequest::getVar('success', 0, 'get');
$dep_id = JRequest::getVar('dep_id', 0, 'get');

$menus = &JSite::getMenu();                                             
$menu  = $menus->getActive();    
$ignore = $menu->query['id']; 
?>

<div id="main" class="p15t">
    <div class="w214 float_left">
        <!-- Menu -->
        <div class="w214 left_menu m10b">
            <div class="left_menu">
                <ul class="parent_menu">    
                    <li class="curr_left_menu">
                        <a href="javascript:void(0);"><?php echo $menu->name; ?></a> 
                        <ul class="child_menu">                                
                            <?php 
                            $layout = $layout ? '&layout=' . $layout : '';                            
                            $sub_menu = $globalModel->getChildrenMenu($menu_id, 0);                                
                            foreach($sub_menu as $value ){ 
                                $params = new JParameter($value['params']);  
                                //$selected = $current_id == $value['id'] ? ' class="active"'   : '';                                
                                $current  = $current_id == $value['id'] ? ' class="curr_sub"' : '';
                                $link = $value['link']. '&Itemid=' . $menu_id . '&id=' . $value['id'];
                                ?>    
                                <li<?php //echo $selected; ?>>
                                    <a <?php echo $current; ?> href="<?php echo $link; ?>" ><?php echo $value['name'];?></a>
                                    <?php 
                                    if($params->get('children') == 1){
                                        $deps = $globalModel->loadDeparments();
                                    ?>  
                                        <ul id="dep_menu">
                                            <?php 
                                            foreach($deps as $dep){ 
                                                $current  = $dep_id == $dep['id'] ? ' class="curr_sub"' : '';
                                                //$link = $value['link'] . '&dep_id=' . $dep['id'] . '&id=' . $value['id'] . '&Itemid=' . $menu_id;
                                                $link = $value['link'] . '&dep_id=' . $dep['id'] . '&Itemid=' . $menu_id;
                                            ?>
                                                <li><a <?php echo $current; ?> href="<?php echo $link; ?>"><?php echo $dep['name']; ?></a></li>
                                            <?php } ?>
                                        </ul>    
                                    <?php } ?>
                                </li>                  
                            <?php } ?> 
                        </ul>
                    </li> 
                </ul>
            </div>
            <div class="left_menu_bot"></div>
        </div>
        
        <!-- Book -->
        <div class="w214 po m10b"> 
            <?php $link = $globalModel->getLeftColumnBookLink(); ?>
            <a href="<?php echo $link; ?>"><img src="<?php echo $template_dir; ?>images/book_banner.png" alt="" /></a>                        
        </div>
        
        <!-- News -->
        <div class="w214">
            <div class="ads_sub_top"></div>
            <div class="ads_sub_mid">
                <div class="w186 mc p10t p10b">
                    <?php                 
                    // Intel Inside   
                    $arr_data2 = $globalModel->getLeftColumnArticle();
                    foreach($arr_data2 as $key => $value){    
                        $text = strip_tags($value['introtext']);
                        $text = strlen($text) > 100 ? mb_substr($text, 0, 100, 'UTF-8') : $text;
                        $link = $globalModel->getLeftColumnArticleLink($value['id']);
                        ?> 
                        <?php if(1==0){ ?>
                        <a href="<?php echo $link; ?>"><img src="<?php echo $template_dir; ?>images/banner_ads_sub.jpg" alt="<?php echo $value['title'];?>" /></a>
                        <?php } ?>
                        <a href="<?php echo $link; ?>"><img src="<?php echo $value['article_image']; ?>" alt="<?php echo $value['title'];?>" /></a>
                            
                        <p class="p5t"><?php echo $text; ?>...<a href="<?php echo $link; ?>"><?php echo JText::_('READ_MORE'); ?></a></p>                            
                    <?php } ?> 
                </div>
            </div>
            <div class="ads_sub_bot"></div>
        </div>
    </div>
    
    <div class="w708 bg_left_col2 float_right p22l">
        <div class="w708 bg_tt_sub1">
            <h2 class="p5t float_left"><?php echo JText::_('ORG_TITLE'); ?></h2>
            <p class="float_right p5t" style="display:none"><a href="#"><img src="<?php echo $template_dir; ?>images/tilbage_icon.png" alt="" /> Tilbage</a></p>
            <br style="clear:both" />
        </div>
        <div class="w708">
            <div class="w708 b1pxb">
                <h2 class="organ_text p10t"><?php echo $dep_id ? $globalModel->getDeparment($dep_id)->name . ' ' . JText::_('ORG_DEP') : JText::_('ORG_ALL'); ?></h2>
            </div>
            
            <?php
            $max_item = $max_item = $this->limit;
            $break = false;
            for ($i = 0; $i < $max_item; $i++){ 
                $item = $this->items[$i];                                  
                $class = $i % 2 == 0 ? 'float_left' : 'float_right'; 
                if($i + $this->limitstart >= $this->total){
                    $break = true;
                    break;
                }         
            ?>   
                <?php if($i % 2 == 0){ ?>
                    <div class="w708 bg_shadow_bot">                 
                <?php } ?>                 
                <div class="w344 <?php echo $class; ?>">
                    <img alt="" class="float_left image_t" src="<?php echo $item->image; ?>"/>
                    <div class="float_right w240">
                        <p class="b1pxb">
                            <b><?php echo $item->position; ?></b><br/>
                            <?php echo $item->name; ?>
                        </p>
                        <p>
                            <?php echo $item->phone; ?><br/>
                            <?php echo $item->cellphone; ?><br/>
                            <a href="mailto:<?php echo $item->email; ?>"><?php echo $item->email; ?></a>
                        </p>
                        <p>
<!--                        	<img src="<?php echo $template_dir; ?>images/skyicon.jpg" alt="" /> -->
                        	<a href="<?php echo $item->link_im; ?>" class="blue_text" target="_blank"><?php echo $item->im; ?></a></p>
                    </div>
                    <div class="cb"></div>
                </div>
                
                <?php if($i % 2 != 0){ ?>
                        <div class="cb"></div>
                    </div>
                <?php } ?>
            <?php } ?>
            <?php if($break){ ?>
                    <div class="cb"></div>
                </div>
            <?php } ?>              
        </div>
        
        <div class="pt w708">
            <ul>
                <?php 
                if ($this->pagination->get('pages.total') > 1){ 
                    echo $this->pagination->getPagesLinks();       
                }
                ?>  
            </ul>
            <br class="cb" />
        </div>
    </div>
    <div class="cb"></div>
</div>

<div id="footer" class="bg_foot_sub">
    <div class="w950 mc p15t p15b">
        <p class="float_left">Copyright © <?php echo date('Y'); ?> <a href="index.html">CAREITEC.DK</a>. All rights reserved.</p>
        <p class="float_right">Design by <a href="http://mywebcreations.dk" target="_blank">My Web Creations</a></p>
        <br style="clear:both" />
    </div>
</div>